<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            纪梵希系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" id ="form_product" onsubmit="return false">
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>产品名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="productName" name="productName" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入要添加的产品名称
                    </div>
                </div>
                   <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>产品分类
                    </label>
                    <div class="layui-input-inline">
                         <select name="productCategoryId">
                            <option value="">请选择系列</option>
                            <option value="1">口红系列</option>
                            <option value="2">气垫系列</option>
                            <option value="3">香水系列</option>
                             <option value="4">眼线系列</option>
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入要添加的产品分类
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red"></span>产品原价格
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="productPrice" name="productPrice" required="" lay-verify="phone"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入要添加的产品价格
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red"></span>产品市场价格
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="salePrice" name="salePrice" required="" lay-verify="email"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入要添加的产品市场价格
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red"></span>品牌
                        
                    </label>
                    <div class="layui-input-inline">
                        <!-- <input type="text" id="brand" name="brand" required="" lay-verify="brand"
                        autocomplete="off" class="layui-input"><br/> -->
                        <select name="brand">
                            <option value="">请选择品牌</option>
                            <option value="纪梵希">纪梵希</option>
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入要添加的产品品牌
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red"></span>产品颜色
                    </label>
                    <div class="layui-input-inline">
                       <!--  <input type="text" id="productColor" name="productColor" required="" lay-verify="email"
                        autocomplete="off" class="layui-input"> -->
                        <select name="productColor">
                            <option value="">请选择颜色</option>
                            <option value="番茄色">番茄色</option>
                            <option value="胡萝卜色">胡萝卜色</option>
                            <option value="牛血色">牛血色</option>
                            <option value="肤色">肤色</option>
                             <option value="黑色">黑色</option>
                             <option value="棕色">棕色</option>
                             <option value="粉色">粉色</option>
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入要添加的产品的颜色
                    </div>
                </div>
                   <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        	产品展示图片:
                    </label>
                    <br/>
                    <img id="imgFace" style="width: 120px" src="" />
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="imgs1">
 							<i class="layui-icon">&#xe67c;</i>上传图片
						</button>
						<input type="hidden" name="imgs" id="imgs"class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red"></span>产品材质
                    </label>
                    <div class="layui-input-inline">
                      <!--   <input type="text" id="getMetails" name="getMetails" required="" lay-verify="email"
                        autocomplete="off" class="layui-input"> -->
                        <select name="getMetails">
                            <option value="">请选择材质</option>
                            <option value="金属">金属</option>
                            <option value="塑料">塑料</option> 
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入要添加的产品的材质
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button  class="layui-btn" lay-filter="add" onclick="addProduct()">
                        	添加
                    </button>
                </div>
            </form>
        </div>
        <script src="./lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="./js/x-layui.js" charset="utf-8">
        </script>
        <script>
        	var $=null;
        	var form = null;
        	var layer = null;
        	var upload = null;
            layui.use(['form','layer','upload'], function(){
                $ = layui.jquery;
               form = layui.form;
              layer = layui.layer;
              upload = layui.upload;
            //执行实例
  			var uploadInst = upload.render({
  				elem : '#imgs1',//绑定元素
  				url : '../adminProductDetailsCategory?reqName=uploadImg', //上传接口
  				acceptMime: 'image/*', 
  				done : function(res) {
  					//上传完毕回调
  					//把返回的图片名，放到img标记的src里面 
  					if(res.success){
  						$("#imgFace").attr("src", "../" + res.remark); //把返回的图片名，保存在隐藏域里面 
  						$("#imgs").val(res.remark);
  						layer.msg('新图片上传成功', {
  							icon : 6,
  							time : 1500
  						});
  					}else{
  						
  					}
  				},
  				error : function() {
  					//请求异常回调
  				}
  			});
    
            });
            
            function addProduct(){
            	//var productName = $("#productName").val();
            	var jg=$("#form_product").serializeArray();
            	console.log(jg)
            	for(var i=0;i<jg.length;i++){
            		if(jg[i].value==null||jg[i].value==""){
            			return false;
            		}
            	}
            	$.post("../adminProductDetailsCategory?reqName=addProductDetailsCategorys",$("#form_product").serialize(),function(res){
            		if (res.success) {
						layer.msg(res.message);
						var index=parent.layer.getFrameIndex(window.name); //获取当前窗口的name
			               parent.layer.close(index);		//关闭窗口
			               parent.$("#table_productDetails").html("");
			               parent.myProductsPage();//调用父亲的selProductDetailsCates()方法
			               
					} else {
						layer.msg(res.message);
					}
            	},"json");
            }
        </script>
        
    </body>

</html>